#include <iostream>
#include <vector>
#include <windows.h>
using namespace std;

class Solution {
public:
    bool canJump(vector<int>& nums) {
        int fastest=0;
        for(int i=0;i<nums.size();i++)
        {
            if(fastest<i) return false;
            fastest=max(fastest,i+nums[i]);
            if(fastest>=nums.size()-1) return true;

        }
        return fastest>=nums.size()-1;
    }
};

void printResult(bool result, const vector<int>& nums) {
    cout << "输入：nums = [";

    for (size_t i = 0; i < nums.size(); ++i) {
        cout << nums[i];
        if (i < nums.size() - 1) cout << ",";
    }

    cout << "]" << endl;
    cout << "输出：" << (result ? "true" : "false") << endl;
}

int main() {
    // 设置控制台输出为UTF-8编码
    SetConsoleOutputCP(CP_UTF8);
    
    Solution s;
    
    // 测试用例1：标准情况，可以到达
    vector<int> nums1 = {2,3,1,1,4};
    cout << "测试用例1 - 标准情况(可到达)：" << endl;
    printResult(s.canJump(nums1), nums1);
    cout << "预期：true" << endl << endl;
    
    // 测试用例2：标准情况，不可到达
    vector<int> nums2 = {3,2,1,0,4};
    cout << "测试用例2 - 标准情况(不可到达)：" << endl;
    printResult(s.canJump(nums2), nums2);
    cout << "预期：false" << endl << endl;
    
    // 测试用例3：单个元素
    vector<int> nums3 = {0};
    cout << "测试用例3 - 单个元素：" << endl;
    printResult(s.canJump(nums3), nums3);
    cout << "预期：true" << endl << endl;
    
    // 测试用例4：全零数组（除第一个元素外）
    vector<int> nums4 = {2,0,0,0};
    cout << "测试用例4 - 连续零：" << endl;
    printResult(s.canJump(nums4), nums4);
    cout << "预期：true" << endl << endl;
    
    // 测试用例5：刚好可以到达
    vector<int> nums5 = {1,1,1,0};
    cout << "测试用例5 - 刚好可以到达：" << endl;
    printResult(s.canJump(nums5), nums5);
    cout << "预期：true" << endl;

    return 0;
}